#ifndef _button_h_
#define _button_h_

#include "main.h"

#define BUTTON_SHORT_PRESSED_TIME_MS (20)
#define BUTTON_REPEAT_TIME_MS (300)
#define BUTTON_LONG_PRESSED_TIME_MS (2000)
#define BUTTONS_NUM (3)
#define IS_BUTTONS_ID (id)(id < BUTTONS_NUM)
#define BUTTON_PIN_VAL_PRESSED (0)
#define BUTTON_PIN_VAL_IS_PRESSED(pin_val) (pin_val == BUTTON_PIN_VAL_PRESSED)
#define BUTTON_READ_PIN_VAL(id) LL_GPIO_IsInputPinSet(KEY##id##_GPIO_Port, KEY##id##_GPIO_Pin)

typedef enum
{
    EVENT_PRESSED,
    EVENT_RELEASED,
    EVENT_REPEAT,
    EVENT_LONG_PRESSED
} button_event_t;

typedef (*button_event_cb_t)(uint8_t id, button_event_t event);

void button_init(void);
void button_check(void);
void button_set_event_cb(button_event_cb_t cb);

#endif /*_button_h_*/